<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        .father {
            position: relative;
            width: 200px;
            height: 200px;
            margin: 100px;
            background-color: pink;
        }
        .son {
            /* position: absolute; */
            background-color: purple;
            width: 45px;
            height: 45px;
            margin: 45px;
        }
        .w {
            width: 200px;
            height: 200px;
            background-color: red;
            margin: -200px auto ;
            padding: 10px;
        }
    </style>
</head>
<body>
    <div class="father">
        <div class="son"></div>
    </div>
    <div class="w"></div>
    <script>
        var father = document.querySelector('.father');
        var son = document.querySelector('.son');
        console.log(father.offsetTop);
        console.log(father.offsetLeft);
        console.log(son.offsetTop);
        console.log(son.offsetLeft);
        var w = document.querySelector('.w');
        console.log(w.offsetWidth);
        console.log(w.offsetHeight);
    </script>
</body>
</html>